package com.ruoyi.customer.service.impl;

import com.ruoyi.customer.domain.Customer;
import com.ruoyi.customer.mapper.CustomerMapper;
import com.ruoyi.customer.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class CustomerServiceImpl implements ICustomerService {

    private final CustomerMapper customerMapper;

    @Autowired
    public CustomerServiceImpl(CustomerMapper customerMapper) {
        this.customerMapper = customerMapper;
    }

    @Override
    public List<Customer> selectCustomerList(Customer customer) {
        return customerMapper.selectCustomerList(customer);
    }

    @Override
    public Customer selectCustomerById(Long customerId) {
        return customerMapper.selectCustomerById(customerId);
    }


    @Override
    public List<Customer> selectCustomerListBycustomerName(String customerName) {
        return customerMapper.selectCustomerListBycustomerName(customerName);
    }

    @Override
    public int insertCustomer(Customer customer) {
        return customerMapper.insertCustomer(customer);
    }

    @Override
    public int updateCustomer(Customer customer) {
        return customerMapper.updateCustomer(customer);
    }

    @Override
    public int changeCustomerStatus(Long customerId, String status) {
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("customerId", customerId);
        paramMap.put("status", status);
        return customerMapper.changeCustomerStatus(paramMap);
    }



    @Override
    public int deleteCustomerByIds(Long[] customerIds) {
        return customerMapper.deleteCustomerByIds(customerIds);
    }

    @Override
    public int deleteCustomerById(Long customerId) {
        return customerMapper.deleteCustomerById(customerId);
    }
}
